﻿using System.Web.UI.WebControls;

namespace MyLib.Web.UI {
	/// <summary>
	/// 
	/// </summary>
	public class MyUserParameter : Parameter {
		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="control"></param>
		/// <returns></returns>
		protected override object Evaluate(System.Web.HttpContext context, System.Web.UI.Control control) {
			if (context.User == null)
				return string.Empty;
			else if (context.User.Identity == null)
				return string.Empty;
			else
				return context.User.Identity.Name;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		protected override System.Web.UI.WebControls.Parameter Clone() {
			var ret = new MyUserParameter();
			ret.Name = Name;
			ret.Size = Size;
			ret.Type = Type;
			ret.ConvertEmptyStringToNull = ConvertEmptyStringToNull;
			ret.DbType = DbType;
			ret.DefaultValue = DefaultValue;
			ret.Direction = Direction;

			return ret;
		}
	} // end of MyUserParameter.
}
